package engine.logic
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Linear;
	
	import flash.display.MovieClip;
	
	import newx.com.control.group.NxViewGroup;

	/**
	 * 容器折叠效果 
	 * @author gf
	 * 
	 */	
	
	public class TurnGroupLogic
	{
		private static var _self:TurnGroupLogic; 
		
		public function TurnGroupLogic(i:privateClass)
		{
			
		}
		
		public static function getInstance():TurnGroupLogic
		{
			if(_self==null)
			{
				_self	=	new TurnGroupLogic(new privateClass);
			}
			return _self;
		}
		
		/**
		 * 
		 * @param ui 缓动容器
		 * @param showIndex 索引值
		 * @param onComplete 完成
		 * @param time 效果时间
		 * @param dis 偏移量
		 * 
		 */		
		public function turnOn(ui:NxViewGroup,showIndex:int=1,onComplete:Function=null,time:Number=1,dis:int=0):void
		{
			var mc:MovieClip	=	ui.getItemByIndex(showIndex);
			var width:int	=	dis!=0?dis:mc.width;
			TweenLite.to(ui, time, {offsetCol:-width, ease:Linear.easeNone,overwrite:true,onComplete:function():void
			{
				if(onComplete !=null) onComplete.call();
			}});
			ui.setChildIndex(mc,ui.numChildren-1);
		}
		
		/**
		 * 
		 * @param ui 缓动容器
		 * @param time 效果时间
		 * 
		 */		
		public function turnOff(ui:NxViewGroup,time:Number=1,offCol:Number=0,onComplete:Function=null):void
		{
			TweenLite.to(ui, time, {offsetCol:offCol, ease:Linear.easeNone,overwrite:true ,onComplete:function():void
			{
				if(onComplete !=null) onComplete.call();
			}});
		}
	}
}
class privateClass{}